//
//  BalanceTableViewCell.m
//  BaishidaiKnight
//
//  Created by mac book on 2019/1/28.
//  Copyright © 2019年 sy. All rights reserved.
//

#import "BalanceTableViewCell.h"


@interface BalanceTableViewCell ()

@property(nonatomic,strong) UILabel* typeLabel;
@property(nonatomic,strong) UILabel* cashLabel;
@property(nonatomic,strong) UILabel* dateLabel;

@end


@implementation BalanceTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self createSubviews];
    }
    return self;
}



#pragma mark - createSubviews

-(void)createSubviews{
    [self.contentView addSubview:self.typeLabel];
    [self.contentView addSubview:self.cashLabel];
    [self.contentView addSubview:self.dateLabel];
    
    
    [self.typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(10);
        make.width.mas_equalTo(self.contentView).multipliedBy(0.4);
        
    }];
    
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(-10);
        make.width.mas_equalTo(self.contentView).multipliedBy(0.3);
        
    }];
    
    [self.cashLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.equalTo(self.contentView);
        make.right.equalTo(self.dateLabel.mas_left);
        make.left.equalTo(self.typeLabel.mas_right);

    }];
    
    
    
}



#pragma mark - setter
-(void)setBalanceModel:(BalanceModel *)balanceModel{
    
    _balanceModel = balanceModel;
    
    self.typeLabel.text = balanceModel.mark;
    if([balanceModel.change_type isEqualToString:@"1"]){
        self.cashLabel.text = [NSString stringWithFormat:@"+%.2f",[balanceModel.amount floatValue]];
    }else{
        self.cashLabel.text = [NSString stringWithFormat:@"%.2f",[balanceModel.amount floatValue]];
    }
    
    self.dateLabel.text = balanceModel.creat_time;
    
}



#pragma mark - 懒加载
-(UILabel *)typeLabel{
    if(!_typeLabel){
        _typeLabel = [[UILabel alloc]init];
        _typeLabel.textColor =kMyColor(130, 130, 130);
        _typeLabel.font = [UIFont systemFontOfSize:14.f];
    }
    return _typeLabel;
}

-(UILabel *)cashLabel{
    if(!_cashLabel){
        _cashLabel = [[UILabel alloc]init];
        _cashLabel.font = [UIFont systemFontOfSize:14.f];
        _cashLabel.textAlignment = NSTextAlignmentCenter;
        self.cashLabel.textColor =kMyColor(241, 8, 0);

    }
    return _cashLabel;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [[UILabel alloc]init];
        _dateLabel.textColor =  kMyColor(130, 130, 130);
        _dateLabel.font = [UIFont systemFontOfSize:14.f];
        _dateLabel.textAlignment = NSTextAlignmentRight;
    }
    return _dateLabel;
}




- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
